package com.uft.model.entity;

import java.io.Serializable;
import java.lang.Integer;
import java.lang.String;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.*;
import static javax.persistence.CascadeType.ALL;
import static javax.persistence.CascadeType.REMOVE;


/**
 * Entity implementation class for Entity: Profile
 *
 */
@Entity
@NamedQueries({
	@NamedQuery(
	name = "getProfilebyName",
	query = "SELECT p FROM Profile p WHERE p.profileName=:profileName"
	),
	@NamedQuery(
	name = "getProfileByServerId",
	query = "SELECT p FROM Profile p JOIN p.servers s WHERE s.serverId = :serverId"
	),
	@NamedQuery(
			name = "getProfileIdByServerId",
			query = "SELECT p.profileId FROM Profile p JOIN p.servers s WHERE s.serverId = :serverId"
	)
})

public class Profile implements Serializable {

	   
	@Id
	@GeneratedValue
	private Integer profileId;
	private String region;
	private String profileName;
	private String hostname;
	private Integer port;
	private String security;
	private String username;
	private String password;
	@OneToMany(cascade = { ALL, REMOVE },fetch=FetchType.EAGER)
	private Set<Server> servers = new HashSet<Server>();
	
	@OneToOne(cascade = { ALL, REMOVE },fetch=FetchType.EAGER)
	private ProfilePreferences profilePref;
	
	private static final long serialVersionUID = 1L;

	public Profile() {
		super();
	}   
	public Integer getProfileId() {
		return this.profileId;
	}

	public void setProfileId(Integer profileId) {
		this.profileId = profileId;
	}   
	public String getRegion() {
		return this.region;
	}

	public void setRegion(String region) {
		this.region = region;
	}   
	public String getProfileName() {
		return this.profileName;
	}

	public void setProfileName(String profileName) {
		this.profileName = profileName;
	}   
	public String getHostname() {
		return this.hostname;
	}

	public void setHostname(String hostname) {
		this.hostname = hostname;
	}   
	public Integer getPort() {
		return this.port;
	}

	public void setPort(Integer port) {
		this.port = port;
	}   
	
	public String getSecurity() {
		return security;
	}
	public void setSecurity(String security) {
		this.security = security;
	}
	public String getUsername() {
		return this.username;
	}

	public void setUsername(String username) {
		this.username = username;
	}   
	public String getPassword() {
		return this.password;
	}

	public void setPassword(String password) {
		this.password = password;
		
	}
	public Set<Server> getServers() {
		return servers;
	}
	public void setServers(Set<Server> servers) {
		this.servers = servers;
	}
	public void addServer(Server server){
		this.servers.add(server);
	}
	
	public ProfilePreferences getProfilePref() {
		if(profilePref == null){
			profilePref = new ProfilePreferences();
		}
		return profilePref;
	}
	public void setProfilePref(ProfilePreferences profilePref) {
		this.profilePref = profilePref;
	}
	
	
	//String Representation:
    @Override
    public String toString() {
        return "ProfileName: "+profileName;
    }
    
   
}
